package com.android.demo_20220829.ui.activity;

import androidx.annotation.NonNull;

import com.android.demo_20220829.BuildConfig;
import com.android.demo_20220829.R;
import com.mapbox.api.directions.v5.DirectionsCriteria;
import com.mapbox.api.directions.v5.models.RouteOptions;
import com.mapbox.geojson.Point;
import com.mapbox.navigation.base.options.EventsAppMetadata;
import com.mapbox.navigation.base.options.NavigationOptions;
import com.mapbox.navigation.base.route.NavigationRoute;
import com.mapbox.navigation.base.route.NavigationRouterCallback;
import com.mapbox.navigation.base.route.RouterFailure;
import com.mapbox.navigation.base.route.RouterOrigin;
import com.mapbox.navigation.core.MapboxNavigation;
import com.mapbox.navigation.core.MapboxNavigationProvider;
import com.mapbox.navigation.dropin.NavigationView;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import butterknife.BindView;

public class NavigationActivity extends BaseActivity {

    @BindView(R.id.navigationview)
    NavigationView navigationview;


    MapboxNavigation mapboxNavigation;




    @Override
    protected int getLayoutId() {
        return R.layout.activity_navigation;
    }

    @Override
    protected void initView() {

//         mapboxNavigation = MapboxNavigationProvider.create(
//                new NavigationOptions.Builder(this)
//                        .accessToken(getString(R.string.mapbox_access_token))
//                        .eventsAppMetadata(
//                                new EventsAppMetadata.Builder(
//                                        BuildConfig.APPLICATION_ID,
//                                        BuildConfig.VERSION_NAME
//                                ).build()
//                        )
//                        .build()
//        );
//        getRouter();
    }

    private void getRouter(Point origin,Point destination){
        List<Point> points = new ArrayList<>();
        points.add(origin);
        points.add(destination);
        mapboxNavigation.requestRoutes(RouteOptions.builder().coordinatesList(points).build(), new NavigationRouterCallback() {
            @Override
            public void onRoutesReady(@NonNull List<NavigationRoute> list, @NonNull RouterOrigin routerOrigin) {

            }

            @Override
            public void onFailure(@NonNull List<RouterFailure> list, @NonNull RouteOptions routeOptions) {

            }

            @Override
            public void onCanceled(@NonNull RouteOptions routeOptions, @NonNull RouterOrigin routerOrigin) {

            }
        });

    }

//    private fun findRoute(origin:Point, destination: Point) {
//        mapboxNavigation.requestRoutes(
//                RouteOptions.builder()
//                        .applyDefaultNavigationOptions()
//                        .applyLanguageAndVoiceUnitOptions(this)
//                        .coordinatesList(listOf(origin, destination))
//                        .layersList(listOf(mapboxNavigation.getZLevel(), null))
//                        .alternatives(false)
//                        .annotationsList(Collections.singletonList(DirectionsCriteria.ANNOTATION_MAXSPEED))
//                        .build(),
//                object : RouterCallback {
//            override fun onRoutesReady(
//                    routes: List<DirectionsRoute>,
//            routerOrigin: RouterOrigin
//                ) {
//                mapboxNavigation.setRoutes(routes)
//            }
//
//            override fun onFailure(
//                    reasons: List<RouterFailure>,
//            routeOptions: RouteOptions
//                ) {
//                // no impl
//            }
//
//            override fun onCanceled(routeOptions: RouteOptions, routerOrigin: RouterOrigin) {
//                // no impl
//            }
//        }
//        )
//    }

    @Override
    protected void initData() {

    }


    //    @OnClick({R.id.tv_sendcode})
//    public void onViewClicked(View view) {
//        switch (view.getId()) {
//            case R.id.tv_sendcode:
//                break;
//        }
//    }
}
